package com.zklh.leetcode.tree.model;

import java.util.LinkedList;
import java.util.List;

/**
 * 二叉树的节点
 *
 * @author 坐看落花
 * @version 1.0
 * @date 2021/1/10 18:02
 */
public class TreeNode {
    public int val;
    public TreeNode left;
    public TreeNode right;

    public TreeNode() {
    }

    public TreeNode(int val) {
        this.val = val;
    }

    public TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }

    @Override
    public String toString() {
        return val + ", "
                + (left == null ? "null" : left.toString())
                + ", " + (right == null ? "null" : right.toString());
    }

    public static void main(String[] args) {
        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.right = new TreeNode(3);
        root.left.right = new TreeNode(5);
        root.right.left = new TreeNode(6);
        System.out.println(root);
    }
}
